﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NORM.Test
{
    public partial class 测试连接 : Form
    {
        public 测试连接()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string Message = string.Empty;
            NORM.DataBase.DataBase db = NORM.DataBase.DataBaseFactory.Create("Server=192.168.0.116;Initial Catalog=CMSConfiguration;User ID=sa;Pwd=YHPych920,.;", NORM.DataBase.DataBaseTypes.SqlDataBase);
            try
            {
                //db.TestConnect(out Message);

                NORM.Common.ConnectionString ConnectionString = new Common.ConnectionString("Data Source=|DataDirectory|fasdb.db;Version=3;Password=4HxbajmTkLY=;UseUTF16Encoding=True;");
                
                string connectionString0 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString0, NORM.DataBase.DataBaseTypes.SqliteDataBase);

                db.TestConnect(out Message);


                ConnectionString = new Common.ConnectionString("Server=192.168.0.116;Initial Catalog=CMSConfiguration;User ID=sa;Pwd=YHPych920,.;"); //Sql Server

                string connectionString1 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString1, NORM.DataBase.DataBaseTypes.SqlDataBase);

                db.TestConnect(out Message);

                ConnectionString = new Common.ConnectionString("Server=192.168.0.116,1433;Initial Catalog=CMSConfiguration;User ID=sa;Pwd=YHPych920,.;"); //Sql Server

                string connectionString2 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString2, NORM.DataBase.DataBaseTypes.SqlDataBase);

                db.TestConnect(out Message);
                
                ConnectionString = new Common.ConnectionString("Server=182.76.17.11;Port=5432;Database=wos;uid=postgres;pwd=postgres;Encoding=UNICODE");//PostgreSql

                string connectionString3 = ConnectionString.connectionString;

                ConnectionString = new Common.ConnectionString();
                ConnectionString.Server = "192.168.0.158";
                ConnectionString.DataBaseName = "DevelopFramework_Base";
                ConnectionString.UserId = "sa";
                ConnectionString.Password = "123456";

                string connectionString4 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString4, NORM.DataBase.DataBaseTypes.SqlDataBase);

                db.TestConnect(out Message);

                ConnectionString = new Common.ConnectionString(NORM.DataBase.DataBaseTypes.SqlDataBase);
                ConnectionString.Server = "192.168.0.158";
                ConnectionString.Port = "1433";
                ConnectionString.DataBaseName = "DevelopFramework_Base";
                ConnectionString.UserId = "sa";
                ConnectionString.Password = "123456";

                string connectionString5 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString5, NORM.DataBase.DataBaseTypes.SqlDataBase);

                db.TestConnect(out Message);


                ConnectionString = new Common.ConnectionString(NORM.DataBase.DataBaseTypes.PostgreSqlDataBase);
                ConnectionString.Server = "192.168.0.158";
                ConnectionString.Port = "5432";
                ConnectionString.DataBaseName = "DevelopFramework_Base";
                ConnectionString.UserId = "sa";
                ConnectionString.Password = "123456";
                ConnectionString.Encoding = "UTF-8";

                string connectionString6 = ConnectionString.connectionString;


                ConnectionString = new Common.ConnectionString(NORM.DataBase.DataBaseTypes.SqliteDataBase);
                ConnectionString.Server = "|DataDirectory|fasdb.db";
                ConnectionString.Version = "3";
                ConnectionString.UseUTF16Encoding = "True";
                ConnectionString.Password = "4HxbajmTkLY=";

                string connectionString7 = ConnectionString.connectionString;

                db = NORM.DataBase.DataBaseFactory.Create(connectionString7, NORM.DataBase.DataBaseTypes.SqliteDataBase);

                db.TestConnect(out Message);                

                MessageBox.Show(Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
